import AdminMain from '@/views/admin/Main'
import HomeMain from '@/views/home/Main'

function loadView(view) {
  return () => import( /* webpackChunkName: "view-[request]" */ `@/views/${view}.vue`)
}
export default [{
    path: '*',
    redirect: {
      path: '/404'
    }
  }, {
    path: '/404',
    name: '404',
    component: loadView('errors/404')
  }, {
    path: '/403',
    name: '403',
    component: loadView('errors/403')
  }, {
    path: '/500',
    name: '500',
    component: loadView('errors/500')
  },
  {
    path: '/',
    name: 'home',
    component: HomeMain,
    meta: {
      requiresAuth: false
    },
    children: [{
        path: '',
        name: 'homepage',
        component: loadView('home/Home')
      }, {
        path: 'archive',
        name: 'archive',
        component: loadView('home/Archive')
      },
      {
        path: 'article/:id',
        name: 'article',
        component: loadView('home/Article')
      }, {
        path: 'page/:id',
        name: 'page',
        component: loadView('home/Page')
      },
      {
        path: 'tag/:id',
        name: 'tag',
        component: loadView('home/Tag')
      },
      {
        path: 'category/:id',
        name: 'category',
        component: loadView('home/Category')
      }, {
        path: 'messages',
        name: 'messages',
        component: loadView('home/Messages')
      },
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: loadView('Login')
  },
  {
    path: '/admin',
    name: 'admin',
    component: AdminMain,
    meta: {
      requiresAuth: false
    },
    redirect: {
      name: 'dashboard'
    },
    children: [{
        path: 'dashboard',
        name: 'dashboard',
        meta: {
          name: '',
          breadcrumb: true
        },
        component: loadView('admin/Dashboard')
      },
      {
        path: 'test1',
        name: 'test1',
        meta: {
          name: '',
          breadcrumb: true
        },
        component: loadView('admin/Test1')
      },
      {
        path: 'stest/test2',
        name: 'test2',
        meta: {
          name: '',
          breadcrumb: true
        },
        component: loadView('admin/Test2')
      },
      {
        path: 'stest/test3',
        name: 'test3',
        meta: {
          name: '',
          breadcrumb: true
        },
        component: loadView('admin/Test3')
      },
    ]
  }
]
